package com.hducms.cms.entity.main;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;


/**
 *  table="jc_group"
 */

public class CmsGroup  implements Serializable {

	private static final long serialVersionUID = 5968594392176566022L;
	public static String REF = "CmsGroup";
	public static String PROP_NEED_CHECK = "needCheck";
	public static String PROP_ALLOW_MAX_FILE = "allowMaxFile";
	public static String PROP_ALLOW_SUFFIX = "allowSuffix";
	public static String PROP_ALLOW_PER_DAY = "allowPerDay";
	public static String PROP_PRIORITY = "priority";
	public static String PROP_NAME = "name";
	public static String PROP_ID = "id";
	public static String PROP_REG_DEF = "regDef";
	public static String PROP_NEED_CAPTCHA = "needCaptcha";


	// constructors
	public CmsGroup () {
	}

	/**
	 * Constructor for primary key
	 */
	public CmsGroup (java.lang.Integer id) {
		this.setId(id);
	}

	/**
	 * Constructor for required fields
	 */
	public CmsGroup (
		java.lang.Integer id,
		java.lang.String name,
		java.lang.Integer priority,
		java.lang.Integer allowPerDay,
		java.lang.Integer allowMaxFile,
		java.lang.Boolean needCaptcha,
		java.lang.Boolean needCheck,
		java.lang.Boolean regDef) {

		this.setId(id);
		this.setName(name);
		this.setPriority(priority);
		this.setAllowPerDay(allowPerDay);
		this.setAllowMaxFile(allowMaxFile);
		this.setNeedCaptcha(needCaptcha);
		this.setNeedCheck(needCheck);
		this.setRegDef(regDef);
	}



	// primary key
	private java.lang.Integer id;

	// fields
	
	// 名称
	private java.lang.String name;		
	// 排列顺序
	private java.lang.Integer priority;
	// 每日允许上传KB
	private java.lang.Integer allowPerDay;
	// 每个文件最大KB
	private java.lang.Integer allowMaxFile;
	// 允许上传的后缀
	private java.lang.String allowSuffix;
	// 是否需要验证码
	private java.lang.Boolean needCaptcha;
	// 是否需要审核
	private java.lang.Boolean needCheck;
	// 是否默认会员组
	private java.lang.Boolean regDef;

	// collections
	private java.util.Set<com.hducms.cms.entity.main.Channel> viewChannels;
	private java.util.Set<com.hducms.cms.entity.main.Channel> contriChannels;



	/**
	 * Return the unique identifier of this class
     * @hibernate.id
     *  generator-class="identity"
     *  column="group_id"
     */
	public java.lang.Integer getId () {
		return id;
	}

	/**
	 * Set the unique identifier of this class
	 * @param id the new ID
	 */
	public void setId (java.lang.Integer id) {
		this.id = id;
	}




	/**
	 * Return the value associated with the column: group_name
	 */
	public java.lang.String getName () {
		return name;
	}

	/**
	 * Set the value related to the column: group_name
	 * @param name the group_name value
	 */
	public void setName (java.lang.String name) {
		this.name = name;
	}


	/**
	 * Return the value associated with the column: priority
	 */
	public java.lang.Integer getPriority () {
		return priority;
	}

	/**
	 * Set the value related to the column: priority
	 * @param priority the priority value
	 */
	public void setPriority (java.lang.Integer priority) {
		this.priority = priority;
	}


	/**
	 * Return the value associated with the column: allow_per_day
	 */
	public java.lang.Integer getAllowPerDay () {
		return allowPerDay;
	}

	/**
	 * Set the value related to the column: allow_per_day
	 * @param allowPerDay the allow_per_day value
	 */
	public void setAllowPerDay (java.lang.Integer allowPerDay) {
		this.allowPerDay = allowPerDay;
	}


	/**
	 * Return the value associated with the column: allow_max_file
	 */
	public java.lang.Integer getAllowMaxFile () {
		return allowMaxFile;
	}

	/**
	 * Set the value related to the column: allow_max_file
	 * @param allowMaxFile the allow_max_file value
	 */
	public void setAllowMaxFile (java.lang.Integer allowMaxFile) {
		this.allowMaxFile = allowMaxFile;
	}


	/**
	 * Return the value associated with the column: allow_suffix
	 */
	public java.lang.String getAllowSuffix () {
		return allowSuffix;
	}

	/**
	 * Set the value related to the column: allow_suffix
	 * @param allowSuffix the allow_suffix value
	 */
	public void setAllowSuffix (java.lang.String allowSuffix) {
		this.allowSuffix = allowSuffix;
	}


	/**
	 * Return the value associated with the column: need_captcha
	 */
	public java.lang.Boolean getNeedCaptcha () {
		return needCaptcha;
	}

	/**
	 * Set the value related to the column: need_captcha
	 * @param needCaptcha the need_captcha value
	 */
	public void setNeedCaptcha (java.lang.Boolean needCaptcha) {
		this.needCaptcha = needCaptcha;
	}


	/**
	 * Return the value associated with the column: need_check
	 */
	public java.lang.Boolean getNeedCheck () {
		return needCheck;
	}

	/**
	 * Set the value related to the column: need_check
	 * @param needCheck the need_check value
	 */
	public void setNeedCheck (java.lang.Boolean needCheck) {
		this.needCheck = needCheck;
	}


	/**
	 * Return the value associated with the column: is_reg_def
	 */
	public java.lang.Boolean getRegDef () {
		return regDef;
	}

	/**
	 * Set the value related to the column: is_reg_def
	 * @param regDef the is_reg_def value
	 */
	public void setRegDef (java.lang.Boolean regDef) {
		this.regDef = regDef;
	}

	@Override
	public String toString() {
		return "CmsGroup [id=" + id + ", name=" + name + ", priority="
				+ priority + ", allowPerDay=" + allowPerDay + ", allowMaxFile="
				+ allowMaxFile + ", allowSuffix=" + allowSuffix
				+ ", needCaptcha=" + needCaptcha + ", needCheck=" + needCheck
				+ ", regDef=" + regDef + "]";
	}
	
	/**
	 * Return the value associated with the column: viewChannels
	 */
	public java.util.Set<com.hducms.cms.entity.main.Channel> getViewChannels () {
		return viewChannels;
	}

	/**
	 * Set the value related to the column: viewChannels
	 * @param viewChannels the viewChannels value
	 */
	public void setViewChannels (java.util.Set<com.hducms.cms.entity.main.Channel> viewChannels) {
		this.viewChannels = viewChannels;
	}


	/**
	 * Return the value associated with the column: contriChannels
	 */
	public java.util.Set<com.hducms.cms.entity.main.Channel> getContriChannels () {
		return contriChannels;
	}

	/**
	 * Set the value related to the column: contriChannels
	 * @param contriChannels the contriChannels value
	 */
	public void setContriChannels (java.util.Set<com.hducms.cms.entity.main.Channel> contriChannels) {
		this.contriChannels = contriChannels;
	}


	/**
	 * 从集合中提取ID数组
	 * 
	 * @param groups
	 * @return
	 */
	public static Integer[] fetchIds(Collection<CmsGroup> groups) {
		Integer[] ids = new Integer[groups.size()];
		int i = 0;
		for (CmsGroup g : groups) {
			ids[i++] = g.getId();
		}
		return ids;
	}
	
	public void init() {
		if (getRegDef() == null) {
			setRegDef(false);
		}
	}
	
//	public Set<Integer> getViewChannelIds() {
//		Set<Channel> channels = getViewChannels();
//		Set<Integer> ids = new HashSet<Integer>();
//		for (Channel c : channels) {
//				ids.add(c.getId());
//		}
//		return ids;
//	}
//	public Set<Integer> getContriChannelIds(Integer siteId) {
//		Set<Channel> channels = getContriChannels();
//		Set<Integer> ids = new HashSet<Integer>();
//		for (Channel c : channels) {
//				ids.add(c.getId());
//		}
//		return ids;
//	}


}